package com.xls.boxlibrary;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.View;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;

import com.xls.boxlibrary.utils.LUtils;

public class WebviewActivity extends AppCompatActivity {
    ImageView title_back;
    WebView wb_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        title_back=findViewById(R.id.title_back);
        wb_view=findViewById(R.id.wb_view);
        title_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        wb_view.setWebViewClient(new WebViewClient(){
            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                super.onReceivedSslError(view, handler, error);
            }

            @Override
            public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
                super.onReceivedError(view, request, error);
                LUtils.e("webview"+request);
            }
        });
        wb_view.loadUrl(getIntent().getStringExtra("url"));

    }
    public static void start(Context activity, String url){
        Intent intent=new Intent(activity,WebviewActivity.class);
        intent.putExtra("url",url);
        activity.startActivity(intent);
    }
}